import java.util.Random;

public class String_test4 {
    //生成一个随机位的字符串验证码,每个位的随机字符是数字、大写字母、小写字母的组合
    public static void main(String[] args) {
        System.out.println(CreateCode(6));
        System.out.println(CreateCode(4));
    }

    public static String CreateCode(int n){
        String code = "";
        String str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        Random index = new Random();

        for (int i = 0; i < n; i++) {
            int data = index.nextInt(str.length());
            code += str.charAt(data);
        }
        return code;
    }

}
